package cn.liuxiany.alibaba.consumer.controller;

import cn.liuxiany.alibaba.common.request.Result;
import cn.liuxiany.alibaba.consumer.entity.Order;
import cn.liuxiany.alibaba.consumer.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author liuxiany
 * @since 2023-10-18
 */
@RestController
@RequestMapping("/order/")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @PostMapping("test/add")
    public void testAdd(@RequestBody Order order) {
        orderService.testAdd(order);
    }

    @PostMapping("test/testAddTransaction")
    public void testAddTransaction(@RequestBody Order order) {
        orderService.testAddTransaction(order);
    }

    @GetMapping("test/get")
    public Result<List<Order>> testGet(String name) {
        List<Order> orders = orderService.testGet(name);

        return Result.success(orders);
    }

    @GetMapping("test/break")
    public String testBreak(String name) {
        return orderService.testBreak(name);
    }

    @PostMapping("test/testGlobalTx")
    public String testGlobalTx(@RequestBody Order order) {
        return orderService.testGlobalTx(order);
    }
}
